package Class::Value::Enum;

# $Id: Enum.pm 8411 2005-02-16 16:04:09Z gr $

use strict;
use warnings;


our $VERSION = '0.04';


use base 'Class::Value';


sub get_valid_values_list           { () }
sub get_value_normalization_hashref { {} }


sub normalize_value {
    my ($self, $value) = @_;
    $self->normalize_enum_value($value);
}


sub normalize_enum_value {
    my ($self, $value) = @_;
    return unless defined $value;
    return $value if grep { $_ eq $value } $self->get_valid_values_list;
    $self->get_value_normalization_hashref->{lc $value};
    # automatically returns undef if it doesn't exist
}


sub as_plaintext {
    my $self = shift;
    my %lookup = reverse %{ $self->get_value_normalization_hashref };
    $lookup{$self->value};
}


1;


__END__

{% USE p = PodGenerated %}

=head1 NAME

{% p.package %} - the Value Object design pattern

=head1 SYNOPSIS

    {% p.package %}->new;

=head1 DESCRIPTION

None yet. This is an early release; fully functional, but undocumented. The
next release will have more documentation.

{% p.write_inheritance %}

=head1 METHODS

=over 4

{% p.write_methods %}

=back

{% PROCESS standard_pod %}

=cut

